let crypto = require('crypto');
let G = {};
G.log = console.log.bind(console);
G.encrypt = function(content,secret){
    var cipher = crypto.createCipher('aes192', secret);
    var enc = cipher.update(content,'utf8','hex');
    enc += cipher.final('hex');
    // console.log('enc:',enc);
    return enc;
};


G.decrypt = function(content,secret){
    G.log('解密信息.  content:',content,";secret: ",secret);
    var decipher = crypto.createDecipher('aes192',secret);
    var dec = decipher.update(content,'hex','utf8');
    dec += decipher.final('utf8');
    return dec;
};


//==========================
// 测试解密信息
let str = "ebff787f319b5dcdb82b1ed481fd9e6e";
console.log(G.decrypt(str,"071024"));


// 测试加密信息
let srcStr = "daihanlong";
console.log(G.encrypt(srcStr,"071024"));
